package xyz.lisys.utils;

import lombok.Data;
import org.springframework.beans.PropertyEditorRegistrar;
import org.springframework.beans.PropertyEditorRegistry;

import java.util.Date;

@Data
public final class CustomPropertyEditorRegistrar implements PropertyEditorRegistrar {
    private String formatter = "yyyy-MM-dd";

    @Override
    public void registerCustomEditors(PropertyEditorRegistry registry) {
        // 这种注册方式可以使用构造函数，除此之外还可以使用 @InitBinder 针对单个 Controller 进行注册
        System.out.println(formatter);
        System.out.println("======================================================");
        registry.registerCustomEditor(Date.class, new DateEditor(formatter));
    }

}
